<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="../img/base.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../img/jquery.js" ></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="../js/jcrop/jquery.Jcrop.js"></script>
<script src="../js/swf/fileprogress.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/swf/swfupload.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/swf/swfupload.queue.js" type="text/javascript" charset="utf-8"></script>
<link rel="stylesheet" href="../js/jcrop/jquery.Jcrop.css" type="text/css" />
<script language="javascript">
    function checkSubmit()
    {
      if(document.form1.admin_name.value == '')
      {
	       alert("请填写企业名称！");
	       return false;
      }  
    }   
</script>
</head>
<body leftmargin='15' topmargin='10' bgcolor="#FFFFFF">
   <form name="form1" action="company_act.php?action=save" enctype="multipart/form-data" method="post" onSubmit="return checkSubmit()">
    <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
	    <td>&nbsp;</td>
	</tr>
    </table>

    <table width="97%" border="0" align="center" cellpadding="0" cellspacing="0" id="head1" style="border-bottom:1px solid #CCCCCC">
	<tr>
	    <td colspan="2">
		<table width="98%" border="0" cellpadding="0" cellspacing="0">
		    <tr>
			<td width="84" height="24" align="center" background="../img/itemnote1.gif">&nbsp;编辑企业&nbsp;</td>
			<td width="84"></td>
			<td>&nbsp;</td>
		    </tr>
		</table>
	    </td>
	</tr>
    </table>
    <table width="98%"  border="0" align="center" cellpadding="2" cellspacing="2" id="needset">
	<tr>
	    <td height="24" colspan="4" class="bline">
		<table width="98%" border="0" cellspacing="0" cellpadding="0">
		    <tr>
				<td class="bline" width="90">&nbsp;企业名称：</td>
				<td class="bline"><input name="company_id" type="hidden" value="<{$company_arr.company_id}>"/><input name="company_name" type="text" value="<{$company_arr.company_name}>" id="admin_name" size="30" class="iptxt" /><span style="color:#F00">*必填</span></td>
		    </tr>
			<tr>
				<td class="bline" width="90">&nbsp;连接：</td>
				<td class="bline"><input name="company_url" type="text" value="<{$company_arr.company_url}>" id="admin_name" size="30" class="iptxt" /></td>
		    </tr>
			<tr>
				<td class="bline" width="90">&nbsp;公司logo：</td>
				<td class="bline" height="34px">
					<div id="smalllogo_box" >
						<{if $company_arr.company_logo neq ''}>
						<input type="hidden"  name="logo" size="40" value="<{$product_arr.logo}>"/><div class="simg_box"><img id="company_logo"  src="../upload/company/<{$company_arr.company_logo}>"/></div>
						<{/if}>
					</div>
				</td>
		    </tr>
			<tr>			
				<td class="bline" width="90">&nbsp;</td>
				<td class="bline" align="left"  >
					  <div class="fieldset flash" style="padding-left: 15px;display:none;"  id="fsUploadProgress1"> </div>
					    <span id="spanButtonPlaceholder1"></span>
                        <input id="btnCancel1" type="hidden" value="Cancel Uploads" onclick="cancelQueue(upload1);" disabled="disabled" style="margin-left: 2px; height: 22px; font-size: 8pt;" />
						<span id="upload_id" style="cursor: pointer;">上传</span>
						<span id="cut_id"  style="line-height: 30px;">裁切</span>
				</td>
			</tr>		
		</table>      
	    </td>
	</tr>
    </table>

    <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
	<tr>
	    <td height="56">
		<table width="98%" border="0" cellspacing="1" cellpadding="1">
		    <tr>
			<td align="center">
			    <table width="214" border="0" cellspacing="0" cellpadding="0" >
				<tr>
				    <td width="115">
					<input name="imageField" type="image" src="../img/button_ok.gif" width="60" height="22" class="np" border="0"  style="cursor:pointer; ">
				    </td>
				    <td width="99">
					 <img src="../img/button_reset.gif" width="60" height="22" border="0" onClick="location.reload();" style="cursor:pointer; ">
				    </td>
				</tr>
			   </table>
			</td>
		    </tr>
		</table>
	    </td>
	</tr>
    </table>
    </form>		<div id="jcrop_id" class="jcrop_box" style="width:100%;height:500px;" >
		<div id="company_logo_box"></div>	
		<div><div id="close_jcrop">关闭</div>		
		<div id="sure_jcrop2">&nbsp;&nbsp;&nbsp;&nbsp;确定裁切</div>			
	</div>
	<input type="hidden" id="left_x"/>
	<input type="hidden" id="left_y"/>
	<input type="hidden" id="bot_x"/>
	<input type="hidden" id="bot_y"/>
	</div>
</body>
</html>
<script type="text/javascript">	
$(function(){	 
  $("#cut_id").click(function(){			
	  $("#sure_jcrop2").show();		
	  $("#jcrop_id").show();
	  var company_logo_src = $("#company_logo").attr("src");
	  $html = '<img id="cropbox"  src="'+company_logo_src+'">';				
	  $("#company_logo_box").empty().append($html);
		  $.Jcrop('#cropbox',{
		  minSize: [0,0],
		  handles:true,			
		  onChange:showCoords,
		  onSelect:showCoords,
		  setSelect: [0,0,82,32]
	  });
  })

  $("#close_jcrop").click(function(){
	  $("#company_logo_box").empty();
	  $("#jcrop_id").hide();			
  })
})

function showCoords(c)
{
   $("#left_x").val(c.x);
   $("#left_y").val(c.y);
   $("#bot_x").val(c.x2);
   $("#bot_y").val(c.y2);
}

$("#sure_jcrop2").click(function(){
	  var img_source = $("#company_logo").attr("src");			
	  $.post(
		  'jcrop2.php',
		  {left_x:$("#left_x").val(),left_y:$("#left_y").val(),bot_x:$("#bot_x").val(),bot_y:$("#bot_y").val(),img_src:img_source},
		  function(callback){

			  var img_name = callback.substr(callback.lastIndexOf('/') + 1);					
			  $("#company_logo_box").empty();
			  $("#jcrop_id").hide();
			  $("#logo_box").empty();
			  var small_box='<div class="simg_box"><img id="company_logo"  src="'+callback+'"/><input type="hidden"  name="company_logo" size="40" value="'+img_name+'"/></div>';

			$("#smalllogo_box").empty().append(small_box)					
		  },
		  'html'
	  )
});

var  swfurl   = "../js/swf/swfupload.swf";
var  phpurl    = "upload.php";
var  buttonurl ="";
var  conurl    = "../upload/company/";
var upload1;
window.onload = function() {
	upload1 = new SWFUpload({
	   upload_url: phpurl,
		post_params: {"PHPSESSID" : "gjc0to5amsgd23p3klaurifuq1"},
		file_size_limit : "1024",	// 200 kb
		file_types : "*.jpg;*.gif;*.png",
		file_types_description : "Image Files",
		file_upload_limit : "0",
		file_queue_limit : "0",
		file_queued_handler : fileQueued,
		file_queue_error_handler : fileQueueError,
		file_dialog_complete_handler : fileDialogComplete,
		upload_start_handler : uploadStart,
		upload_progress_handler : uploadProgress,
		upload_error_handler : uploadError,
		upload_success_handler : uploadSucces,
		upload_complete_handler : uploadComplete,
		queue_complete_handler : queueComplete,
		button_image_url : buttonurl,
		button_placeholder_id : "upload_id",
		button_width: "88",
		button_height: "26",
		button_text: '上传',
		button_text_style: ".theFont {font-size: 16;z-index=0;}",
		button_text_left_padding: 30,
		button_text_top_padding: 10,
		flash_url : swfurl,
		 swfupload_element_id : "flashUI2",
		degraded_element_id : "degradedUI2",
		custom_settings : {
				progressTarget : "fsUploadProgress1",
				cancelButtonId : "btnCancel1"
		},
		debug: false
	});	
}

function fileQueued(file) {
	var progress = new FileProgress(file, this.customSettings.progressTarget);
	progress.setStatus("正在等待...");
	progress.toggleCancel(true, this);
}
function fileQueueError(file, errorCode, message) {
}
function fileDialogComplete(numFilesSelected, numFilesQueued) {
	if (numFilesSelected > 0) {
			document.getElementById(this.customSettings.cancelButtonId).disabled = false;
	}
	this.startUpload();
}
function uploadStart(file) {
	var progress = new FileProgress(file, this.customSettings.progressTarget);
	progress.setStatus("正在上传...");
	progress.toggleCancel(true, this);
	return true;
}
function uploadProgress(file, bytesLoaded, bytesTotal) {
	var percent = Math.ceil((bytesLoaded / bytesTotal) * 100);
	var progress = new FileProgress(file, this.customSettings.progressTarget);
	progress.setProgress(percent);
	progress.setStatus("正在上传...");
}

function uploadSucces(file, serverData) {
	var progress = new FileProgress(file, this.customSettings.progressTarget);
	progress.setComplete();
	progress.setStatus("上传成功");
	progress.toggleCancel(false);
		var larg_box='<div class="simg_box"><img id="company_logo"  src="'+conurl+serverData+'"/><input type="hidden"   name="company_logo" size="40" value="'+serverData+'"/></div>';
	$("#smalllogo_box").empty().append(larg_box);
}

function uploadError(file, errorCode, message) {
}
function uploadComplete(file) {
	if (this.getStats().files_queued === 0) {
			document.getElementById(this.customSettings.cancelButtonId).disabled = true;
	}
}
function queueComplete(numFilesUploaded) {
	//	var status = document.getElementById("divStatus");
	//	status.innerHTML = numFilesUploaded + " 个文件" + (numFilesUploaded === 1 ? "" : "s") + "已上传.";
}
</script>
					